title | description |
---|---|
Migrate Your MySQL Database to Supabase |
Migrate your MySQL database to Supabase Postgres database. |
This guide aims to exhibit the process of transferring your MySQL database to Supabase's Postgres database. Supabase is a robust and open-source platform offering a wide range of backend features, including a PostgreSQL database, authentication, instant APIs, edge functions, real-time subscriptions, and storage. Migrating your MySQL database to Supabase's PostgreSQL enables you to leverage PostgreSQL's capabilities and access all the features you need for your project.
Before you begin the migration, you need to collect essential information about your MySQL database. Follow these steps:
-
Log in to your MySQL database provider.
-
Locate and note the following database details:
- Hostname or IP address
- Database name
- Username
- Password
-
If you're new to Supabase, create a project. Make a note of your password, you will need this later. If you forget it, you can reset it here.
-
Go to the Database settings for your project in the Supabase Dashboard.
-
Under Connection Info, note your Host (
$SUPABASE_HOST
).
The fastest way to migrate your database is with the Supabase migration tool on Google Colab.
Alternatively, you can use pgloader, a flexible and powerful data migration tool that supports a wide range of source database engines, including MySQL and MS SQL, and migrates the data to a Postgres database. For databases using the Postgres engine, we recommend using the pg_dump
and psql command line tools, which are included in a full PostgreSQL installation.
<Tabs scrollable size="small" type="underlined" defaultActiveId="colab" queryGroup="migrate-method"
- Select the Dabase Engine from the Source database in the dropdown
- Set the environment variables (
HOST
,USER
,SOURCE_DB
,PASSWORD
,SUPABASE_URL
, andSUPABASE_PASSWORD
) in the Colab notebook. - Run the first two steps in the notebook in order. The first sets engine and installs the necessary files.
- Run the third step to start the migration. This will take a few minutes.
Install pgloader.
Create a configuration file (e.g., config.load).
For your destination, use your Supabase connection string with `Use connection pooling` enabled, and the mode set to `Session`. You can get the string from your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/general).
load database
from mysql://user:password@host/source_db
into postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:5432/postgres
alter schema 'public' owner to 'postgres';
set wal_buffers = '64MB', max_wal_senders = 0, statement_timeout = 0, work_mem to '2GB';
pgloader config.load